#include "D3DUtils.h"

#include <cassert>

#include "main/D3DData.h"
#include "main/Globals.h"

// Copies the content from the buffer to the buffer 
// that will be used by the GPU.
// This call should be made as infrequently as possible.
void 
copyData(const void* data, const size_t sizeData, ID3D11Buffer& buffer) {
	assert(Globals::gD3D->mImmediateContext);
	ID3D11DeviceContext& context = *Globals::gD3D->mImmediateContext;

    D3D11_MAPPED_SUBRESOURCE mappedResource;
    D3D11_MAP mapType = D3D11_MAP_WRITE_DISCARD;
    context.Map(&buffer, 0, mapType, 0, &mappedResource);
    CopyMemory(mappedResource.pData, data, sizeData);
    context.Unmap(&buffer, 0);
}